package com.hxgz.steel.service.Impl;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.hxgz.steel.common.KdniaoTrackQueryAPI;
import com.hxgz.steel.common.ServerResponse;
import com.hxgz.steel.config.WeChatConfig;
import com.hxgz.steel.dao.*;
import com.hxgz.steel.domain.*;
import com.hxgz.steel.dto.*;
import com.hxgz.steel.service.NewOrderService;
import com.hxgz.steel.util.CommonUtils;
import com.hxgz.steel.util.OSSClientUtil;
import com.hxgz.steel.util.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;

@Service
public class NewOrderServiceImpl implements NewOrderService {

    @Autowired
    private QuotationMapper quotationMapper;
    @Autowired
    private AskInfoMapper askInfoMapper;
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private OrderItemMapper orderItemMapper;
    @Autowired
    private MerchantMapper merchantMapper;
    @Autowired
    private QuotationInfoMapper quotationInfoMapper;
    @Autowired
    private AskBuyMapper askBuyMapper;
    @Autowired
    public OSSClientUtil ossutil;
    @Autowired
    public WeChatConfig weChatConfig;
    @Autowired
    public OSSClientUtil ossClientUtil;


    @Override
    public ServerResponse getOrderDetailByBuyer(String id) {
        OrderDetailDto orderDetailDto = orderMapper.checkOrderList(id);
        Order order = orderMapper.selectByPrimaryKey(Long.valueOf(id));//获取订单表的实体数据
        List<OrderItemTimeDto> orderItemTimeDtos = this.newGetOrderItemByOrderId(order.getId(),order.getQuotationId());
        orderDetailDto.setOrderItemList(orderItemTimeDtos);
        Long quotationId = order.getQuotationId();
        if (order.getQuotationId() != null) {
            /**
             * 实单求购订单
             */
            Quotation quotation = quotationMapper.selectByPrimaryKey(quotationId);
            BigDecimal freight = quotation.getFreight(); //商家报价的运费
            BigDecimal taxPoint = quotation.getTaxPoint(); //商家报价的税点
            BigDecimal taxation = quotation.getTaxation();//商家报价的税费
            BigDecimal price = quotation.getPrice();//报价商家给出的报价
            BigDecimal totalPrice = quotation.getTotalPrice();//报价商家给出的总报价
            if (freight != null) {
                orderDetailDto.setPostage(freight.toString());
            } else {
                orderDetailDto.setPostage("0");
            }
            if (taxPoint != null) {
                orderDetailDto.setTaxPoint(taxPoint.toString());
            } else {
                orderDetailDto.setTaxPoint("0");
            }
            if (taxation != null) {
                orderDetailDto.setTaxation(taxation.toString());
            } else {
                orderDetailDto.setTaxation("0");
            }
            orderDetailDto.setOfferPrice(price);
            orderDetailDto.setAllPrice(totalPrice);
        } else {
            /**
             * 商城订单无税费
             */
            orderDetailDto.setTaxPoint("0");
            orderDetailDto.setTaxation("0");
            if (order.getPostage() == null) {
                orderDetailDto.setOfferPrice(orderDetailDto.getAllPrice());
            } else {
                orderDetailDto.setOfferPrice(orderDetailDto.getAllPrice().subtract(order.getPostage()));
            }
        }
        orderDetailDto.setIdentityStatus("0");
        Map<Object, Object> map = new HashMap<>();
        map.put("info", orderDetailDto);
//    实单信息求购表geo_ask_info中取出area设置进去
        List<OrderItemTimeDto> orderItemList = orderDetailDto.getOrderItemList();
        if (quotationId != null) {
            Quotation quotation = quotationMapper.selectByPrimaryKey(quotationId);
            Long askId = quotation.getAskId();
            List<AskInfo> askInfos = askInfoMapper.selectByAskId(askId);
            if (askInfos.size() == orderItemList.size()) {
                for (int i = 0; i < askInfos.size(); i++) {
                    AskInfo askInfo = askInfos.get(i);
                    OrderItemTimeDto orderItemTimeDto = orderItemList.get(i);
                    orderItemTimeDto.setCategoryName(askInfo.getKind());
                    orderItemTimeDto.setProductName(askInfo.getProductName());
                    orderItemTimeDto.setFeatures(askInfo.getSpecification());
                    orderItemTimeDto.setMaterials(askInfo.getTexture());
                    orderItemTimeDto.setTopName(askInfo.getCommodity());
                    orderItemTimeDto.setQuantity(Integer.valueOf(askInfo.getQuantity()));
                    orderItemTimeDto.setUnit(askInfo.getUnit());
                    orderItemTimeDto.setArea(askInfo.getArea());
                }
            }
        }
        map.put("data", orderItemList);
        //收货人信息，发货人信息
        ReceiverDto dto = orderMapper.getRevicer(Long.valueOf(id));
        if (order.getLogistics() != null) {
            dto.setLogistics(order.getLogistics());
        } else {
            dto.setLogistics("");
        }
        if (order.getLogisticsNum() != null) {
            dto.setLogisticsNum(order.getLogisticsNum());
        } else {
            dto.setLogisticsNum("");
        }
        map.put("receiver", dto == null ? new ReceiverDto() : dto);
        //判断是否为商家自己发货
        String result = "";
        if ("QSH".equals(orderDetailDto.getLogistics())) {
            result = orderDetailDto.getLogisticsNum();
        } else {
            //获取物流信息
            KdniaoTrackQueryAPI api = new KdniaoTrackQueryAPI();
            try {
                result = api
                        .getOrderTracesByJson(orderDetailDto.getLogistics(),
                                orderDetailDto.getLogisticsNum());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        map.put("result", result);
        return ServerResponse.createBySuccess(map);
    }


    @Override
    public ServerResponse getOrderDetailSeller(Long id, Long userId) {
        OrderDetailDto orderDetailDto = orderMapper.checkOrderList(id.toString());
        Order order = orderMapper.selectByPrimaryKey(id);//获取订单表的实体数据
        List<OrderItemTimeDto> orderItemTimeDtos = this.newGetOrderItemByOrderId(order.getId(),order.getQuotationId());
        orderDetailDto.setOrderItemList(orderItemTimeDtos);

        //    通过订单id在实单求购表中匹配店铺id而得到税费和税点并设置进orderDetailDto
        Long quotationId = order.getQuotationId();
        if (order.getQuotationId() != null) {
            /**
             * 实单求购订单
             */
            Quotation quotation = quotationMapper.selectByPrimaryKey(quotationId);
            BigDecimal freight = quotation.getFreight(); //商家报价的运费
            BigDecimal taxPoint = quotation.getTaxPoint(); //商家报价的税点
            BigDecimal taxation = quotation.getTaxation();//商家报价的税费
            BigDecimal price = quotation.getPrice();//报价商家给出的报价
            BigDecimal totalPrice = quotation.getTotalPrice();//报价商家给出的总报价
            if (freight != null) {
                orderDetailDto.setPostage(freight.toString());
            } else {
                orderDetailDto.setPostage("0");
            }
            if (taxPoint != null) {
                orderDetailDto.setTaxPoint(taxPoint.toString());
            } else {
                orderDetailDto.setTaxPoint("0");
            }
            if (taxation != null) {
                orderDetailDto.setTaxation(taxation.toString());
            } else {
                orderDetailDto.setTaxation("0");
            }
            orderDetailDto.setOfferPrice(price);
            orderDetailDto.setAllPrice(totalPrice);
        } else {
            /**
             * 商城订单无税费
             */
            orderDetailDto.setTaxPoint("0");
            orderDetailDto.setTaxation("0");
            if (order.getPostage() == null) {
                orderDetailDto.setOfferPrice(orderDetailDto.getAllPrice());
            } else {
                orderDetailDto.setOfferPrice(orderDetailDto.getAllPrice().subtract(order.getPostage()));
            }
        }
        orderDetailDto.setIdentityStatus("1");
        Map<Object, Object> map = new HashMap<>();
        map.put("info", orderDetailDto);
        //    实单信息求购表geo_ask_info中取出area设置进去
        List<OrderItemTimeDto> orderItemList = orderDetailDto.getOrderItemList();
        if (quotationId != null) {
            Quotation quotation = quotationMapper.selectByPrimaryKey(quotationId);
            Long askId = quotation.getAskId();
            List<AskInfo> askInfos = askInfoMapper.selectByAskId(askId);
            if (askInfos.size() == orderItemList.size()) {
                for (int i = 0; i < askInfos.size(); i++) {
                    AskInfo askInfo = askInfos.get(i);
                    OrderItemTimeDto orderItemTimeDto = orderItemList.get(i);
                    orderItemTimeDto.setCategoryName(askInfo.getKind());
                    orderItemTimeDto.setProductName(askInfo.getProductName());
                    orderItemTimeDto.setFeatures(askInfo.getSpecification());
                    orderItemTimeDto.setMaterials(askInfo.getTexture());
                    orderItemTimeDto.setTopName(askInfo.getCommodity());
                    orderItemTimeDto.setQuantity(Integer.valueOf(askInfo.getQuantity()));
                    orderItemTimeDto.setUnit(askInfo.getUnit());
                    orderItemTimeDto.setArea(askInfo.getArea());
                }
            }
        }
        map.put("data", orderItemList);
        ReceiverDto dto = orderMapper.getRevicer(id);
        if (order.getLogistics() != null) {
            dto.setLogistics(order.getLogistics());
        } else {
            dto.setLogistics("");
        }
        if (order.getLogisticsNum() != null) {
            dto.setLogisticsNum(order.getLogisticsNum());
        } else {
            dto.setLogisticsNum("");
        }
        map.put("receiver", dto == null ? new ReceiverDto() : dto);
        //判断是否为商家自己发货
        String result = "";
        if (dto != null) {
            if ("QSH".equals(dto.getLogistics())) {
                result = dto.getLogisticsNum();
            } else {
                //获取物流信息
                KdniaoTrackQueryAPI api = new KdniaoTrackQueryAPI();
                try {
                    result = api.getOrderTracesByJson(dto.getLogistics(), dto.getLogisticsNum());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } else {
            return ServerResponse.createBySuccessMessage("系统异常,请联系客服!!!");
        }
        map.put("result", result);
        return ServerResponse.createBySuccess(map);
    }

    @Override
    public ServerResponse getOrderDetailMiniPrograms(Long userId, Long orderId) {
        OrderDetailDto orderDetailDto = orderMapper.WXcheckOrderList(orderId);
        Order order = orderMapper.selectByPrimaryKey(orderId);//获取订单表的实体数据
        List<OrderItemTimeDto> orderItemTimeDtos =this.newGetOrderItemByOrderId(order.getId(),order.getQuotationId());
        orderDetailDto.setOrderItemList(orderItemTimeDtos);
        Map map = new HashMap();
        map.put("info", orderDetailDto);
        //    实单信息求购表geo_ask_info中取出area设置进去
        List<OrderItemTimeDto> orderItemList = orderDetailDto.getOrderItemList();
        if (order.getQuotationId() != null) {
            Quotation quotation = quotationMapper.selectByPrimaryKey(order.getQuotationId());
            Long askId = quotation.getAskId();
            List<AskInfo> askInfos = askInfoMapper.selectByAskId(askId);
            if (askInfos.size() == orderItemList.size()) {
                for (int i = 0; i < askInfos.size(); i++) {
                    AskInfo askInfo = askInfos.get(i);
                    OrderItemTimeDto orderItemTimeDto = orderItemList.get(i);
                    orderItemTimeDto.setCategoryName(askInfo.getKind());
                    orderItemTimeDto.setProductName(askInfo.getProductName());
                    orderItemTimeDto.setFeatures(askInfo.getSpecification());
                    orderItemTimeDto.setMaterials(askInfo.getTexture());
                    orderItemTimeDto.setTopName(askInfo.getCommodity());
                    orderItemTimeDto.setQuantity(Integer.valueOf(askInfo.getQuantity()));
                    orderItemTimeDto.setUnit(askInfo.getUnit());
                    orderItemTimeDto.setArea(askInfo.getArea());
                }
            }
        } else {
            orderDetailDto.setTaxPoint("0");
            orderDetailDto.setTaxation("0");
        }
        map.put("data", orderItemList);
        ReceiverDto dto = orderMapper.getRevicer(orderId);
        map.put("receiver", dto == null ? new ReceiverDto() : dto);
        //判断是否为商家自己发货
        String result = "";
        if (dto != null) {
            if ("QSH".equals(dto.getLogistics())) {
                result = dto.getLogisticsNum();
            } else {
                //获取物流信息
                KdniaoTrackQueryAPI api = new KdniaoTrackQueryAPI();
                try {
                    result = api.getOrderTracesByJson(dto.getLogistics(), dto.getLogisticsNum());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } else {
            return ServerResponse.createBySuccessMessage("系统异常,请联系客服!!!");
        }
        map.put("result", result);
        return ServerResponse.createBySuccess(map);
    }

    @Override
    @Transactional
    public ServerResponse askBuyPay(NewOrderAskBuyPayDto vo,
                                    HttpServletRequest httpServletRequest, User user) throws Exception {
        Long quotationId = vo.getQuotationId();
        Quotation quotation = quotationMapper.selectByPrimaryKey(quotationId);
        Merchant merchant = merchantMapper.selectByPrimaryKey(quotation.getMerchantId());
        /**
         * order
         */
        Order order = new Order();
        order.setMerchantId(quotation.getMerchantId());
        order.setMerchantName(merchant.getName());
        order.setQuotationId(quotationId);
        order.setAddressId(vo.getAddressId());
        order.setOrderNo(CommonUtils.generateUUID());
        order.setUserId(vo.getUserId());
        order.setMoney(quotation.getTotalPrice());
        order.setPayment(quotation.getTotalPrice());
        order.setPaymentType(0);
        order.setPostage(quotation.getFreight());
        order.setStatus(0);
        order.setStatusSeller(0);
        if (quotation.getMerchantId() == 1) {
            order.setSelfSupport(1);
        } else {
            order.setSelfSupport(0);
        }
        order.setInvoice(vo.getInvoice());
        /**
         * 订单佣金=总价*店铺的佣金
         */
        String commission = merchant.getCommission();
        if (StringUtils.isNotBlank(commission)) {
            order.setBrokerage(
                    new BigDecimal(commission).divide(new BigDecimal("100")).multiply(order.getPayment()));
        } else {
            order.setBrokerage(new BigDecimal("0"));
        }
        order.setRemark(vo.getRemark());
        order.setCreateTime(new Date());
        order.setUpdateTime(new Date());
        orderMapper.insertSelective(order);
        /**
         * orderItem
         */
        List<ListByQuotationIdAndAskInfoIdDto> list = quotationInfoMapper
                .getListByQuotationId(quotationId, quotation.getAskId());
        if (CollectionUtils.isEmpty(list)) {
            //自有文件
            OrderItem orderItem = new OrderItem();
            orderItem.setOrderId(order.getId());
            orderItem.setUserId(vo.getUserId());
            orderItem.setCreateTime(new Date());
            /**
             * 历史原因:这里存储整个订单的价格
             */
            orderItem.setTotalPrice(order.getPayment());
            orderItemMapper.insertSelective(orderItem);
        } else {
            for (ListByQuotationIdAndAskInfoIdDto temp : list) {
                OrderItem orderItem = new OrderItem();
                orderItem.setOrderId(order.getId());
                orderItem.setUserId(vo.getUserId());
                orderItem.setCreateTime(new Date());
                orderItem.setProductName(temp.getProductName());
                orderItem.setCurrentUnitPrice(temp.getCurrentUnitPrice());
                orderItem.setQuantity(temp.getQuantity());
                /**
                 * 历史原因:这里存储整个订单的价格
                 */
                orderItem.setTotalPrice(order.getPayment());
                /**
                 * 后期改P处理
                 */
                orderItemMapper.insertSelective(orderItem);
            }
        }

        String ip = IpUtils.getIpAddr(httpServletRequest);
        String tradeNo = CommonUtils.generateUUID();
        TreeMap<String, String> sortedMap = new TreeMap<>();
        sortedMap.put("appid", PropertiesUtil.getProperty1("wxopen.appid"));
        sortedMap.put("mch_id", weChatConfig.getMchId());
        /*sortedMap.put("device_info", "WEB");*/
        sortedMap.put("nonce_str", CommonUtils.generateUUID());
        sortedMap.put("body", "实单求购订单");
        sortedMap.put("out_trade_no", order.getOrderNo());
        sortedMap.put("total_fee",
                String.valueOf(order.getPayment().multiply(new BigDecimal(100)).intValue()));
        sortedMap.put("spbill_create_ip", ip);
        sortedMap.put("notify_url", weChatConfig.getPayCallbackUrl());
        sortedMap.put("openid", user.getOpenid());
        sortedMap.put("trade_type", "JSAPI");
        String sign = WXPayUtil.createSign(sortedMap, weChatConfig.getKey());
        sortedMap.put("sign", sign);
        String payxml = WXPayUtil.mapToXml(sortedMap);
        String orderStr = HttpTools
                .doPost(WeChatConfig.getUnifiedOrderUrl(), payxml, 4000);
        Map<String, String> unifiedOrderMap = WXPayUtil.xmlToMap(orderStr);
        String prepayId = unifiedOrderMap.get("prepay_id");
        if (StringUtils.isEmpty(prepayId)) {
            ServerResponse.createByErrorMessage("支付错误");
        }
        TreeMap<String, String> finalpackage = new TreeMap<>();
        String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
        String s = CommonUtils.generateUUID();
        String packages = "prepay_id=" + prepayId;
        finalpackage.put("appId", PropertiesUtil.getProperty1("wxopen.appid"));
        finalpackage.put("timeStamp", timestamp);
        finalpackage.put("nonceStr", s);
        finalpackage.put("package", packages);
        finalpackage.put("signType", "MD5");
        String finalsign = WXPayUtil.createSign(finalpackage, weChatConfig.getKey());
        HashMap<String, String> rstMap = Maps.newHashMap();
        rstMap.put("appId", weChatConfig.getAppId());
        rstMap.put("timeStamp", timestamp);
        rstMap.put("nonceStr", s);
        rstMap.put("packageValue", packages);
        rstMap.put("paySign", finalsign);
        rstMap.put("total_fee",
                String.valueOf(order.getPayment().multiply(new BigDecimal(100)).intValue()));
        return ServerResponse.createBySuccess(rstMap);
    }

    @Override
    public ServerResponse getAskFileUrlByMiniPrograms(Long askId, HttpServletResponse response,
                                                      HttpServletRequest request) {
        /**
         *  //读数据库
         *         //存文件
         *         //返回文件地址给他
         */
        InputStream in = null;
        AskBuy askBuy = askBuyMapper.selectByPrimaryKey(askId);
        if (StringUtils.isNotBlank(askBuy.getAskFileUrl())) {
            return ServerResponse.createBySuccess(askBuy.getAskFileUrl());
        }
        List<AskInfo> list = askInfoMapper.getInfoListByAskId(askId);
        List<Map<String, String>> dataList = Lists.newArrayList();
        for (AskInfo vo : list) {
            Map<String, String> dataMap = Maps.newHashMap();
            dataMap.put("分类", vo.getKind());
            dataMap.put("品名", vo.getCommodity());
            dataMap.put("商品名称", vo.getProductName());
            dataMap.put("材质", vo.getTexture());
            dataMap.put("规格", vo.getSpecification());
            dataMap.put("数量", vo.getQuantity());
            dataMap.put("单位", vo.getUnit());
            dataMap.put("地区", vo.getArea());
            dataMap.put("报价(单价)", "0");
            dataList.add(dataMap);
        }
        String excelName = "ASK" + CommonUtils.generateUUID();
        String[] columnName = {"分类", "品名", "商品名称", "材质", "规格", "数量", "单位", "地区","报价(单价)"};
        ExcelUtil util = ExcelUtil.getInstance();
        Workbook workbook = util.dataToExcel(dataList, excelName, columnName);
        //临时缓冲区
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        //创建临时文件
        try {
            workbook.write(out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        byte[] bookByteAry = out.toByteArray();
        in = new ByteArrayInputStream(bookByteAry);
        MultipartFile multipartFile=null;
        String uuid = UUID.randomUUID().toString();
        try {
            multipartFile = new MockMultipartFile(uuid+".xlsx", uuid+".xlsx", "", in);
        } catch (IOException e) {
            e.printStackTrace();
        }
        UploadPic pic = new UploadPic();
        String filePath = pic.upload(multipartFile);
        File file = new File(filePath);
        String fileName = file.getName();
        //文件请求路径
        String pealPath = PropertiesUtil.getProperty("file.server.peal") + fileName;
//        Random random = new Random();
//        String name = random.nextInt(10000) + System.currentTimeMillis() + ".xlsx";
//        ossClientUtil.uploadFile2OSS(in, name);
//        String imgUrl = ossClientUtil.getImgUrl(name);
        return ServerResponse.createBySuccess(pealPath);
    }

    @Override
    public ServerResponse getQuotationFileUrlByMiniPrograms(Long quotationId, HttpServletResponse response, HttpServletRequest request) {
        /**
         *  读数据库
         *  存文件
         *  返回文件地址给他
         */
        InputStream in;
        List<AskInfo> list = askInfoMapper.getInfoListByQuotationId(quotationId);
        if (CollectionUtils.isEmpty(list)) {
            Quotation quotation = quotationMapper.selectByPrimaryKey(quotationId);
            return ServerResponse.createBySuccess(quotation.getQuotationFileUrl());
        }
        List<Map<String, String>> dataList = Lists.newArrayList();
        for (AskInfo vo : list) {
            Map<String, String> dataMap = Maps.newHashMap();
            dataMap.put("分类", vo.getKind());
            dataMap.put("品名", vo.getCommodity());
            dataMap.put("商品名称", vo.getProductName());
            dataMap.put("材质", vo.getTexture());
            dataMap.put("规格", vo.getSpecification());
            dataMap.put("数量", vo.getQuantity());
            dataMap.put("单位", vo.getUnit());
            dataMap.put("地区", vo.getArea());
            dataMap.put("报价(单价)", vo.getPrice().toString());
            dataList.add(dataMap);
        }
        String excelName = "QUO" + CommonUtils.generateUUID();
        String[] columnName = {"分类", "品名", "商品名称", "材质", "规格", "数量", "单位", "地区", "报价(单价)"};
        ExcelUtil util = ExcelUtil.getInstance();
        Workbook workbook = util.dataToExcel(dataList, excelName, columnName);
        //临时缓冲区
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        //创建临时文件
        try {
            workbook.write(out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        byte[] bookByteAry = out.toByteArray();
        in = new ByteArrayInputStream(bookByteAry);
        MultipartFile multipartFile=null;
        String uuid = UUID.randomUUID().toString();
        try {
            multipartFile = new MockMultipartFile(uuid+".xlsx", uuid+".xlsx", "", in);
        } catch (IOException e) {
            e.printStackTrace();
        }
        UploadPic pic = new UploadPic();
        String filePath = pic.upload(multipartFile);
        File file = new File(filePath);
        String fileName = file.getName();
        //文件请求路径
        String pealPath = PropertiesUtil.getProperty("file.server.peal") + fileName;

//        Random random = new Random();
//        String name = random.nextInt(10000) + System.currentTimeMillis() + ".xlsx";
//        ossClientUtil.uploadFile2OSS(in, name);
//        String imgUrl = ossClientUtil.getImgUrl(name);
        return ServerResponse.createBySuccess(pealPath);
    }


    @Override
    public List<OrderItemTimeDto> newGetOrderItemByOrderId(Long orderId,Long quotationId) {
        List<OrderItemTimeDto> orderItemTimeDtos;
        if (quotationId != null) {
            orderItemTimeDtos = orderItemMapper.getOrderItemAskInfoByOrderId(orderId);
        } else {
            orderItemTimeDtos = orderItemMapper.getOrderItemByOrderId(orderId);
        }
        return orderItemTimeDtos;
    }

}
